package com.woniu.car.controller;



import com.woniu.car.common.ResponseEntity;

import com.woniu.car.exception.ServiceSException;
import com.woniu.car.param.AddCategoryChildParam;
import com.woniu.car.param.AddGoodsCategoryParam;
import com.woniu.car.service.TProductCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author chestnuts
 * @since 2021-06-21
 */
@Api(tags = "商品分类模块")
@RestController
@RequestMapping("/tProductCategory")
public class TProductCategoryController {

    @Resource
    private TProductCategoryService productCategoryService;



//    @ApiOperation("添加一个商品种类")
//    @PostMapping("addProductCategory")
//    ResponseEntity addProductCategory(@Validated AddGoodsCategoryParam addGoodsCategoryParam) throws ServiceSException {
//        ResponseEntity responseEntity;
//
//            responseEntity=productCategoryService.addProCategory(addGoodsCategoryParam);
//
//        return responseEntity;
//    }

    @ApiOperation("查询所有一级种类")
    @GetMapping("getLevel")
    ResponseEntity getLevel(){
        ResponseEntity responseEntity;
            responseEntity=productCategoryService.getLevel();
        return responseEntity;
    }

    @ApiOperation("添加一级商品种类")
    @PostMapping("addParentCategory")
    ResponseEntity addParentCategory(@RequestParam(value = "categoryName") String categoryName ) throws ServiceSException {
        ResponseEntity responseEntity;

        responseEntity=productCategoryService.addParentCategory(categoryName);

        return responseEntity;
    }

    @ApiOperation("添加一级商品种类下的子分类")
    @PostMapping("addChildCategory")
    ResponseEntity addChildCategory(@Validated AddCategoryChildParam addCategoryChildParam) throws ServiceSException {
        ResponseEntity responseEntity;

        responseEntity=productCategoryService.addChildCategory(addCategoryChildParam);

        return responseEntity;
    }

//    @ApiOperation("添加一级商品种类下的子分类")
//    @PostMapping("addChildCategory")
//    ResponseEntity getCategoryInfo(@Validated AddCategoryChildParam addCategoryChildParam) throws ServiceSException {
//        ResponseEntity responseEntity;
//
//        responseEntity=productCategoryService.addChildCategory(addCategoryChildParam);
//
//        return responseEntity;
//    }

//    @ApiOperation("查询所有一级种类")
//    @PostMapping("getLevel")
//    ResponseEntity getLevel(){
//        ResponseEntity responseEntity;
//        responseEntity=productCategoryService.getLevel();
//        return responseEntity;
//    }



    @ApiOperation("查看所有的分类和等级")
    @GetMapping("lookAllCategory")
    ResponseEntity selectAllCateGory(){
        ResponseEntity responseEntity = productCategoryService.selectAllCateGory();
        return responseEntity;
    }


//    @ApiOperation("修改一个商品分类")
//    @PutMapping("putOneCategory")
//    ResponseEntity putOneCategory(@Validated PutCategoryParam putCategoryParam ){
//        ResponseEntity responseEntity = productCategoryService.selectAllCateGory();
//        return responseEntity;
//    }

//    @ApiOperation("查看一个分类的详情")
//    @PostMapping("queryCategory")
//    ResponseEntity queryCateGory(@RequestParam(value = "categoryId",required = true) Integer categoryId){
//        ResponseEntity responseEntity = productCategoryService.selectAllCateGory();
//        return responseEntity;
//    }

}

